package com.xbongbong.pro.statistic.enums;

import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.AssembleEnum;
import com.xbongbong.saas.enums.business.BomBillEnum;
import com.xbongbong.saas.enums.business.ClueEnum;
import com.xbongbong.saas.enums.business.CommunicatePlanEnum;
import com.xbongbong.saas.enums.business.ContactEnum;
import com.xbongbong.saas.enums.business.ContractEnum;
import com.xbongbong.saas.enums.business.ContractOutstockEnum;
import com.xbongbong.saas.enums.business.CustomerManagementEnum;
import com.xbongbong.saas.enums.business.DistributorContactEnum;
import com.xbongbong.saas.enums.business.DistributorEnum;
import com.xbongbong.saas.enums.business.FundTransferEnum;
import com.xbongbong.saas.enums.business.InstockEnum;
import com.xbongbong.saas.enums.business.InventoryEnum;
import com.xbongbong.saas.enums.business.InvoiceEnum;
import com.xbongbong.saas.enums.business.MarketActivityEnum;
import com.xbongbong.saas.enums.business.OrderOutStockEnum;
import com.xbongbong.saas.enums.business.OtherExpenseEnum;
import com.xbongbong.saas.enums.business.OtherIncomeEnum;
import com.xbongbong.saas.enums.business.OutstockEnum;
import com.xbongbong.saas.enums.business.PayPlanEnum;
import com.xbongbong.saas.enums.business.PaySheetEnum;
import com.xbongbong.saas.enums.business.PaymentEnum;
import com.xbongbong.saas.enums.business.PaymentSheetEnum;
import com.xbongbong.saas.enums.business.ProductEnum;
import com.xbongbong.saas.enums.business.ProductionInstockEnum;
import com.xbongbong.saas.enums.business.ProductionMaterielOutstockEnum;
import com.xbongbong.saas.enums.business.ProductionOrderEnum;
import com.xbongbong.saas.enums.business.PurchaseEnum;
import com.xbongbong.saas.enums.business.PurchaseInstockEnum;
import com.xbongbong.saas.enums.business.PurchaseInvoiceEnum;
import com.xbongbong.saas.enums.business.QuotationEnum;
import com.xbongbong.saas.enums.business.RefundEnum;
import com.xbongbong.saas.enums.business.RefundInstockEnum;
import com.xbongbong.saas.enums.business.ReturnedMaterielInstockEnum;
import com.xbongbong.saas.enums.business.ReturnedPurchaseEnum;
import com.xbongbong.saas.enums.business.ReturnedPurchaseOutstockEnum;
import com.xbongbong.saas.enums.business.SalesOpportunityEnum;
import com.xbongbong.saas.enums.business.SupplierCommunicateEnum;
import com.xbongbong.saas.enums.business.SupplierContactEnum;
import com.xbongbong.saas.enums.business.SupplierEnum;
import com.xbongbong.saas.enums.business.TransferEnum;
import com.xbongbong.saas.enums.business.WarehouseEnum;
import com.xbongbong.saas.enums.business.WorkOrderEnum;
import com.xbongbong.saas.enums.business.WorkOrderOutstockEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 自定义穿透支持链接详情页的字段枚举
 *
 * @author zhachenhong
 * @version v1.0
 * @date 2022/10/27 13:59
 * @since v1.0
 */
@Getter
public enum LinkDetailFieldEnum {

    /**
     * CRM - 客户 - 客户名称
     */
    CRM_CUSTOMER_NAME(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), CustomerManagementEnum.NAME.getAttr()),
    /**
     * CRM - 联系人 - 姓名
     */
    CRM_CONTACT_NAME(XbbRefTypeEnum.CONTACT.getCode(), ContactEnum.NAME.getAttr()),
    /**
     * CRM - 访客计划 - 访客计划名称
     */
    CRM_COMMUNICATE_PLAN_NAME(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), CommunicatePlanEnum.NAME.getAttr()),
    /**
     * CRM - 销售机会 - 销售机会名称
     */
    CRM_SALES_OPPORTUNITY_NAME(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), SalesOpportunityEnum.NAME.getAttr()),
    /**
     * CRM - 销售机会 - 销售机会编号
     */
    CRM_SALES_OPPORTUNITY_SERIALNUMBER(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), SalesOpportunityEnum.SERIAL_NO.getAttr()),
    /**
     * CRM - 报价编号
     */
    CRM_QUOTATION_SERIALNUMBER(XbbRefTypeEnum.QUOTATION.getCode(), QuotationEnum.QUOTATION_NO.getAttr()),
    /**
     * CRM - 报价名称
     */
    CRM_QUOTATION_NAME(XbbRefTypeEnum.QUOTATION.getCode(), QuotationEnum.NAME.getAttr()),
    /**
     * CRM - 合同编号
     */
    CRM_CONTRACT_SERIALNUMBER(XbbRefTypeEnum.CONTRACT.getCode(), ContractEnum.CONTRACT_NO.getAttr()),
    /**
     * CRM - 合同名称
     */
    CRM_CONTRACT_NAME(XbbRefTypeEnum.CONTRACT.getCode(), ContractEnum.NAME.getAttr()),
    /**
     * CRM - 退货退款单编号
     */
    CRM_REFUND_SERIALNUMBER(XbbRefTypeEnum.REFUND.getCode(), RefundEnum.REFUND_NO.getAttr()),
    /**
     * CRM - 退货退款合同名称
     */
    CRM_REFUND_NAME(XbbRefTypeEnum.REFUND.getCode(), RefundEnum.REFUND_NAME.getAttr()),



    /**
     * 产品 - 产品名称
     */
    PRODUCT_PRODUCT_NAME(XbbRefTypeEnum.PRODUCT.getCode(), ProductEnum.NAME.getAttr()),
    /**
     * 产品 - 产品编号
     */
    PRODUCT_PRODUCT_SERIALNUMBER(XbbRefTypeEnum.PRODUCT.getCode(), ProductEnum.SERIALNO.getAttr()),



    /**
     * 资金 - 回款单编号 / 经销商回款单编号
     */
    FUND_MANAGEMENT_PAYMENT_SHEET_SERIALNUMBER(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), PaymentSheetEnum.SHEET_NO.getAttr()),
    /**
     * 资金 - 应收款编号 / 经销商应收款编号
     */
    FUND_MANAGEMENT_PAYMENT_SERIALNUMBER(XbbRefTypeEnum.PAYMENT.getCode(), PaymentEnum.PAYMENT_NO.getAttr()),
    /**
     * 资金 - 付款计划编号
     */
    FUND_MANAGEMENT_PAY_PLAN_SERIALNUMBER(XbbRefTypeEnum.PAY_PLAN.getCode(), PayPlanEnum.PAY_PLAN_NO.getAttr()),
    /**
     * 资金 - 付款单编号
     */
    FUND_MANAGEMENT_PAY_SHEET_SERIALNUMBER(XbbRefTypeEnum.PAY_SHEET.getCode(), PaySheetEnum.PAY_PLAN_NO.getAttr()),
    /**
     * 资金 - 经销商销项发票编号 / 销项发票编号
     */
    FUND_MANAGEMENT_INVOICE_SERIALNUMBER(XbbRefTypeEnum.INVOICE.getCode(), InvoiceEnum.SHEET_NO.getAttr()),
    /**
     * 资金 - 其他收入单编号
     */
    FUND_MANAGEMENT_OTHER_INCOME_SERIALNUMBER(XbbRefTypeEnum.OTHER_INCOME.getCode(), OtherIncomeEnum.SHEET_NO.getAttr()),
    /**
     * 资金 - 其他支出单编号
     */
    FUND_MANAGEMENT_OTHER_EXPENSE_SERIALNUMBER(XbbRefTypeEnum.OTHER_EXPENSE.getCode(), OtherExpenseEnum.SHEET_NO.getAttr()),
    /**
     * 资金 - 进项发票编号
     */
    FUND_MANAGEMENT_PURCHASE_INVOICE_SERIALNUMBER(XbbRefTypeEnum.PURCHASE_INVOICE.getCode(), PurchaseInvoiceEnum.SHEET_NO.getAttr()),
    /**
     * 资金 - 资金调拨单编号
     */
    FUND_MANAGEMENT_FUND_TRANSFER_SERIALNUMBER(XbbRefTypeEnum.FUND_TRANSFER.getCode(), FundTransferEnum.SHEET_NO.getAttr()),



    /**
     * 进销存 - 仓库
     */
    JXC_WAREHOUSE_NAME(XbbRefTypeEnum.WAREHOUSE.getCode(), WarehouseEnum.WAREHOUSE_NAME.getAttr()),
    /**
     * 进销存 - 仓库编号
     */
    JXC_WAREHOUSE_SERIALNUMBER(XbbRefTypeEnum.WAREHOUSE.getCode(), WarehouseEnum.WAREHOUSE_NO.getAttr()),
    /**
     * 进销存 - 采购入库编号
     */
    JXC_PURCHASE_STORAGE_SERIALNUMBER(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), PurchaseInstockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 供应商名称
     */
    JXC_SUPPLIER_NAME(XbbRefTypeEnum.SUPPLIER.getCode(), SupplierEnum.SUPPLIER_NAME.getAttr()),
    /**
     * 进销存 - 其他入库编号
     */
    JXC_OTHER_WAREHOUSE_SERIALNUMBER(XbbRefTypeEnum.OTHER_INSTOCK.getCode(), InstockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 生产入库编号
     */
    JXC_PRODUCT_WAREHOUSE_SERIALNUMBER(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), ProductionInstockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 生产退料编号
     */
    JXC_RETURNED_MATERIEL_INSTOCK_SERIALNUMBER(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), ReturnedMaterielInstockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 销售退货入库
     */
    JXC_REFUND_INSTOCK_SERIALNUMBER(XbbRefTypeEnum.REFUND_INSTOCK.getCode(), RefundInstockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 出库发货单编号
     */
    JXC_ORDER_OUTSTOCK_SERIALNUMBER(XbbRefTypeEnum.ORDER_OUTSTOCK.getCode(), OrderOutStockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 销售出库编号
     */
    JXC_CONTRACT_OUTSTOCK_SERIALNUMBER(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), ContractOutstockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 采购退货出库编号
     */
    JXC_RETURNED_PURCHASE_OUTSTOCK_SERIALNUMBER(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), ReturnedPurchaseOutstockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 其他出库编号
     */
    JXC_OTHER_OUTSTOCK_SERIALNUMBER(XbbRefTypeEnum.OTHER_OUTSTOCK.getCode(), OutstockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 生产领料编号
     */
    JXC_PRODUCTION_MATERIEL_OUTSTOCK_SERIALNUMBER(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), ProductionMaterielOutstockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 工单出库编号
     */
    JXC_WORK_ORDER_OUTSTOCK_SERIALNUMBER(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(), WorkOrderOutstockEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 供应商联系人
     */
    JXC_SUPPLIER_CONTACT_NAME(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), SupplierContactEnum.NAME.getAttr()),
    /**
     * 进销存 - 采购合同编号
     */
    JXC_PURCHASE_SERIALNUMBER(XbbRefTypeEnum.PURCHASE.getCode(), PurchaseEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 采购退货单编号
     */
    JXC_RETURNED_PURCHASE_SERIALNUMBER(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(), ReturnedPurchaseEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - BOM编号
     */
    JXC_BOM_BILL_SERIALNUMBER(XbbRefTypeEnum.BOM_BILL.getCode(), BomBillEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - BOM名称
     */
    JXC_BOM_BILL_NAME(XbbRefTypeEnum.BOM_BILL.getCode(), BomBillEnum.NAME.getAttr()),
    /**
     * 进销存 - 生产单编号
     */
    JXC_PRODUCTION_ORDER_SERIALNUMBER(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), ProductionOrderEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 装配单编号
     */
    JXC_ASSEMBLE_SERIALNUMBER(XbbRefTypeEnum.ASSEMBLE.getCode(), AssembleEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 盘点单编号
     */
    JXC_INVENTORY_SERIALNUMBER(XbbRefTypeEnum.INVENTORY.getCode(), InventoryEnum.SHEET_NO.getAttr()),
    /**
     * 进销存 - 调拨单编号
     */
    JXC_TRANSFER_SERIALNUMBER(XbbRefTypeEnum.TRANSFER.getCode(), TransferEnum.SHEET_NO.getAttr()),



    /**
     * 市场活动 - 市场活动名称
     */
    MARKET_ACTIVITY_NAME(XbbRefTypeEnum.MARKET_ACTIVITY.getCode(), MarketActivityEnum.NAME.getAttr()),
    /**
     * 市场活动 - 企业名称
     */
    MARKET_ACTIVITY_CLUE_NAME(XbbRefTypeEnum.CLUE.getCode(), ClueEnum.COMPANY_NAME.getAttr()),



    /**
     * 工单 - 工单编号
     */
    WORK_ORDER_SERIALNUMBER(XbbRefTypeEnum.WORK_ORDER.getCode(), WorkOrderEnum.SHEET_NO.getAttr()),
    /**
     * 工单 - 工单名称
     */
    WORK_ORDER_NAME(XbbRefTypeEnum.WORK_ORDER.getCode(), WorkOrderEnum.NAME.getAttr()),



    /**
     * 经销商 - 经销商名称 - 客户标识为经销商
     */
    JXC_DISTRIBUTOR_MANAGEMENT_NAME(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), DistributorEnum.NAME.getAttr()),
    /**
     * 经销商 - 经销商联系人 - 联系人标识为经销商
     */
    JXC_DISTRIBUTOR_CONTACT_NAME(XbbRefTypeEnum.CONTACT.getCode(), DistributorContactEnum.NAME.getAttr()),



    /**
     * 订单中心 - 订货单编号
     */
    ORDER_CENTER_CONTRACT_SERIALNUMBER(XbbRefTypeEnum.CONTRACT.getCode(), ContractEnum.CONTRACT_NO.getAttr()),
    /**
     * 订单中心 - 退货单编号
     */
    ORDER_CENTER_REFUND_SERIALNUMBER(XbbRefTypeEnum.REFUND.getCode(), RefundEnum.REFUND_NO.getAttr()),

    /**
     * 新工单 - 工单编号
     */
    WORK_ORDER_V2_SERIALNUMBER(XbbRefTypeEnum.WORK_ORDER_V2.getCode(), ContractEnum.CONTRACT_NO.getAttr()),

    /**
     * 新工单 - 工单名称
     */
    WORK_ORDER_V2_NAME(XbbRefTypeEnum.WORK_ORDER_V2.getCode(), ContractEnum.NAME.getAttr()),


    ;



    LinkDetailFieldEnum(Integer businessType, String originalAttr) {
        this.businessType = businessType;
        this.originalAttr = originalAttr;
    }

    public static List<String> getLinkDetailAttrByBusinessType(Integer businessType) {
        List<String> list = new ArrayList<>();
        LinkDetailFieldEnum[] cache = LinkDetailFieldEnum.values();
        for (LinkDetailFieldEnum linkDetailFieldEnum : cache) {
            if (Objects.equals(linkDetailFieldEnum.getBusinessType(), businessType)) {
                list.add(linkDetailFieldEnum.getOriginalAttr());
            }
        }
        return list;
    }

    /**
     * 业务类型
     */
    private final Integer businessType;

    /**
     * 多表下的原属性
     */
    private final String originalAttr;

}
